home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / emacs-complete / fsf / emacs / info / emacs-17 < prev    next >
Encoding:
GNU Info File  |  1994-10-06  |  48.8 KB  |  1,164 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.54 from the
  2. input file emacs.texi.
  3.  
  4. 
  5. File: emacs,  Node: File Variables,  Prev: Locals,  Up: Variables
  6.  
  7. Local Variables in Files
  8. ------------------------
  9.  
  10.    A file can specify local variable values for use when you edit the
  11. file with Emacs.  Visiting the file checks for local variables
  12. specifications; it automatically makes these variables local to the
  13. buffer, and sets them to the values specified in the file.
  14.  
  15.    There are two ways to specify local variable values: in the first
  16. line, or with a local variables list.  Here's how to specify them in the
  17. first line:
  18.  
  19.      -*- mode: MODENAME; VAR: VALUE; ... -*-
  20.  
  21. You can specify any number of variables/value pairs in this way, each
  22. pair with a colon and semicolon as shown above.  `mode: MODENAME;'
  23. specifies the major mode; this should come first in the line.  The
  24. VALUEs are not evaluated; they are used literally.  Here is an example
  25. that specifies Lisp mode and sets two variables with numeric values:
  26.  
  27.      ;; -*-Mode: Lisp; fill-column: 75; comment-column: 50; -*-
  28.  
  29.    A "local variables list" goes near the end of the file, in the last
  30. page.  (It is often best to put it on a page by itself.)  The local
  31. variables list starts with a line containing the string `Local
  32. Variables:', and ends with a line containing the string `End:'.  In
  33. between come the variable names and values, one set per line, as
  34. `VARIABLE: VALUE'.  The VALUEs are not evaluated; they are used
  35. literally.
  36.  
  37.    Here is an example of a local variables list:
  38.  
  39.      ;;; Local Variables: ***
  40.      ;;; mode:lisp ***
  41.      ;;; comment-column:0 ***
  42.      ;;; comment-start: ";;; "  ***
  43.      ;;; comment-end:"***" ***
  44.      ;;; End: ***
  45.  
  46.    As you see, each line starts with the prefix `;;; ' and each line
  47. ends with the suffix ` ***'.  Emacs recognizes these as the prefix and
  48. suffix based on the first line of the list, by finding them surrounding
  49. the magic string `Local Variables:'; then it automatically discards
  50. them from the other lines of the list.
  51.  
  52.    The usual reason for using a prefix and/or suffix is to embed the
  53. local variables list in a comment, so it won't confuse other programs
  54. that the file is intended as input for.  The example above is for a
  55. language where comment lines start with `;;; ' and end with `***'; the
  56. local values for `comment-start' and `comment-end' customize the rest
  57. of Emacs for this unusual syntax.  Don't use a prefix (or a suffix) if
  58. you don't need one.
  59.  
  60.    Two "variable names" have special meanings in a local variables
  61. list: a value for the variable `mode' really sets the major mode, and a
  62. value for the variable `eval' is simply evaluated as an expression and
  63. the value is ignored.  `mode' and `eval' are not real variables;
  64. setting variables named `mode' and `eval' in any other context has no
  65. special meaning.  If `mode' is used in a local variables list, it
  66. should be the first entry in the list.
  67.  
  68.    The start of the local variables list must be no more than 3000
  69. characters from the end of the file, and must be in the last page if the
  70. file is divided into pages.  Otherwise, Emacs will not notice it is
  71. there.  The purpose of this rule is so that a stray `Local Variables:'
  72. not in the last page does not confuse Emacs, and so that visiting a
  73. long file that is all one page and has no local variables list need not
  74. take the time to search the whole file.
  75.  
  76.    You may be tempted to try to turn on Auto Fill mode with a local
  77. variable list.  That is a mistake.  The choice of Auto Fill mode or not
  78. is a matter of individual taste, not a matter of the contents of
  79. particular files.  If you want to use Auto Fill, set up major mode
  80. hooks with your `.emacs' file to turn it on (when appropriate) for you
  81. alone (*note Init File::.).  Don't try to use a local variable list
  82. that would impose your taste on everyone.
  83.  
  84.    The variable `enable-local-variables' controls whether to process
  85. local variables lists, and thus gives you a chance to override them.
  86. Its default value is `t', which means do process local variables lists.
  87. If you set the value to `nil', Emacs simply ignores local variables
  88. lists.  Any other value says to query you about each local variables
  89. list, showing you the local variables list to consider.
  90.  
  91.    The `eval' "variable", and certain actual variables, create a
  92. special risk; when you visit someone else's file, local variable
  93. specifications for these could affect your Emacs in arbitrary ways.
  94. Therefore, the option `enable-local-eval' controls whether Emacs
  95. processes `eval' variables, as well variables with names that end in
  96. `-hook', `-hooks', `-function' or `-functions', and certain other
  97. variables.  The three possibilities for the option's value are `t',
  98. `nil', and anything else, just as for `enable-local-variables'.  The
  99. default is `maybe', which is neither `t' nor `nil', so normally Emacs
  100. does ask for confirmation about file settings for these variables.
  101.  
  102.    Use the command `normal-mode' to reset the local variables and major
  103. mode of a buffer according to the file name and contents, including the
  104. local variables list if any.  *Note Choosing Modes::.
  105.  
  106. 
  107. File: emacs,  Node: Keyboard Macros,  Next: Key Bindings,  Prev: Variables,  Up: Customization
  108.  
  109. Keyboard Macros
  110. ===============
  111.  
  112.    A "keyboard macro" is a command defined by the user to stand for
  113. another sequence of keys.  For example, if you discover that you are
  114. about to type `C-n C-d' forty times, you can speed your work by
  115. defining a keyboard macro to do `C-n C-d' and calling it with a repeat
  116. count of forty.
  117.  
  118. `C-x ('
  119.      Start defining a keyboard macro (`start-kbd-macro').
  120.  
  121. `C-x )'
  122.      End the definition of a keyboard macro (`end-kbd-macro').
  123.  
  124. `C-x e'
  125.      Execute the most recent keyboard macro (`call-last-kbd-macro').
  126.  
  127. `C-u C-x ('
  128.      Re-execute last keyboard macro, then add more keys to its
  129.      definition.
  130.  
  131. `C-x q'
  132.      When this point is reached during macro execution, ask for
  133.      confirmation (`kbd-macro-query').
  134.  
  135. `M-x name-last-kbd-macro'
  136.      Give a command name (for the duration of the session) to the most
  137.      recently defined keyboard macro.
  138.  
  139. `M-x insert-kbd-macro'
  140.      Insert in the buffer a keyboard macro's definition, as Lisp code.
  141.  
  142. `C-x C-k'
  143.      Edit a previously defined keyboard macro (`edit-kbd-macro').
  144.  
  145.    Keyboard macros differ from ordinary Emacs commands in that they are
  146. written in the Emacs command language rather than in Lisp.  This makes
  147. it easier for the novice to write them, and makes them more convenient
  148. as temporary hacks.  However, the Emacs command language is not powerful
  149. enough as a programming language to be useful for writing anything
  150. intelligent or general.  For such things, Lisp must be used.
  151.  
  152.    You define a keyboard macro while executing the commands which are
  153. the definition.  Put differently, as you define a keyboard macro, the
  154. definition is being executed for the first time.  This way, you can see
  155. what the effects of your commands are, so that you don't have to figure
  156. them out in your head.  When you are finished, the keyboard macro is
  157. defined and also has been, in effect, executed once.  You can then do
  158. the whole thing over again by invoking the macro.
  159.  
  160. * Menu:
  161.  
  162. * Basic Kbd Macro::  Defining and running keyboard macros.
  163. * Save Kbd Macro::   Giving keyboard macros names; saving them in files.
  164. * Kbd Macro Query::  Keyboard macros that do different things each use.
  165.  
  166. 
  167. File: emacs,  Node: Basic Kbd Macro,  Next: Save Kbd Macro,  Up: Keyboard Macros
  168.  
  169. Basic Use
  170. ---------
  171.  
  172.    To start defining a keyboard macro, type the `C-x (' command
  173. (`start-kbd-macro').  From then on, your keys continue to be executed,
  174. but also become part of the definition of the macro.  `Def' appears in
  175. the mode line to remind you of what is going on.  When you are
  176. finished, the `C-x )' command (`end-kbd-macro') terminates the
  177. definition (without becoming part of it!).  For example,
  178.  
  179.      C-x ( M-f foo C-x )
  180.  
  181. defines a macro to move forward a word and then insert `foo'.
  182.  
  183.    The macro thus defined can be invoked again with the `C-x e' command
  184. (`call-last-kbd-macro'), which may be given a repeat count as a numeric
  185. argument to execute the macro many times.  `C-x )' can also be given a
  186. repeat count as an argument, in which case it repeats the macro that
  187. many times right after defining it, but defining the macro counts as
  188. the first repetition (since it is executed as you define it).
  189. Therefore, giving `C-x )' an argument of 4 executes the macro
  190. immediately 3 additional times.  An argument of zero to `C-x e' or `C-x
  191. )' means repeat the macro indefinitely (until it gets an error or you
  192. type `C-g').
  193.  
  194.    If you wish to repeat an operation at regularly spaced places in the
  195. text, define a macro and include as part of the macro the commands to
  196. move to the next place you want to use it.  For example, if you want to
  197. change each line, you should position point at the start of a line, and
  198. define a macro to change that line and leave point at the start of the
  199. next line.  Then repeating the macro will operate on successive lines.
  200.  
  201.    After you have terminated the definition of a keyboard macro, you
  202. can add to the end of its definition by typing `C-u C-x ('.  This is
  203. equivalent to plain `C-x (' followed by retyping the whole definition
  204. so far.  As a consequence it re-executes the macro as previously
  205. defined.
  206.  
  207.    You can use function keys in a keyboard macro, just like keyboard
  208. keys.  You can even use mouse events, but be careful about that: when
  209. the macro replays the mouse event, it uses the original mouse position
  210. of that event, the position that the mouse had while you were defining
  211. the macro.  The effect of this may be hard to predict.  (Using the
  212. current mouse position would be even less predictable.)
  213.  
  214.    One thing that doesn't always work well in a keyboard macro is the
  215. command `C-M-c' (`exit-recursive-edit').  When this command exits a
  216. recursive edit that started within the macro, it works as you'd expect.
  217. But if it exits a recursive edit that started before you invoked the
  218. keyboard macro, it also necessarily exits the keyboard macro as part of
  219. the process.
  220.  
  221.    You can edit a keyboard macro already defined by typing `C-x C-k'
  222. (`edit-kbd-macro').  Follow that with the keyboard input that you would
  223. use to invoke the macro--`C-x e' or `M-x NAME' or some other key
  224. sequence.  This formats the macro definition in a buffer and enters a
  225. specialized major mode for editing it.  Type `C-h m' once in that
  226. buffer to display details of how to edit the macro.  When you are
  227. finished editing, type `C-c C-c'.
  228.  
  229. 
  230. File: emacs,  Node: Save Kbd Macro,  Next: Kbd Macro Query,  Prev: Basic Kbd Macro,  Up: Keyboard Macros
  231.  
  232. Naming and Saving Keyboard Macros
  233. ---------------------------------
  234.  
  235.    If you wish to save a keyboard macro for longer than until you
  236. define the next one, you must give it a name using `M-x
  237. name-last-kbd-macro'.  This reads a name as an argument using the
  238. minibuffer and defines that name to execute the macro.  The macro name
  239. is a Lisp symbol, and defining it in this way makes it a valid command
  240. name for calling with `M-x' or for binding a key to with
  241. `global-set-key' (*note Keymaps::.).  If you specify a name that has a
  242. prior definition other than another keyboard macro, an error message is
  243. printed and nothing is changed.
  244.  
  245.    Once a macro has a command name, you can save its definition in a
  246. file.  Then it can be used in another editing session.  First, visit
  247. the file you want to save the definition in.  Then use this command:
  248.  
  249.      M-x insert-kbd-macro RET MACRONAME RET
  250.  
  251. This inserts some Lisp code that, when executed later, will define the
  252. same macro with the same definition it has now.  (You need not
  253. understand Lisp code to do this, because `insert-kbd-macro' writes the
  254. Lisp code for you.)  Then save the file.  You can load the file later
  255. with `load-file' (*note Lisp Libraries::.).  If the file you save in is
  256. your init file `~/.emacs' (*note Init File::.) then the macro will be
  257. defined each time you run Emacs.
  258.  
  259.    If you give `insert-kbd-macro' a numeric argument, it makes
  260. additional Lisp code to record the keys (if any) that you have bound to
  261. the keyboard macro, so that the macro will be reassigned the same keys
  262. when you load the file.
  263.  
  264. 
  265. File: emacs,  Node: Kbd Macro Query,  Prev: Save Kbd Macro,  Up: Keyboard Macros
  266.  
  267. Executing Macros with Variations
  268. --------------------------------
  269.  
  270.    Using `C-x q' (`kbd-macro-query'), you can get an effect similar to
  271. that of `query-replace', where the macro asks you each time around
  272. whether to make a change.  While defining the macro, type `C-x q' at
  273. the point where you want the query to occur.  During macro definition,
  274. the `C-x q' does nothing, but when you run the macro later, `C-x q'
  275. asks you interactively whether to continue.
  276.  
  277.    The valid responses when `C-x q' asks are SPC (or `y'), DEL (or
  278. `n'), ESC (or `q'), `C-l' and `C-r'.  The answers are the same as in
  279. `query-replace', though not all of the `query-replace' options are
  280. meaningful.
  281.  
  282.    These responses include SPC to continue, and DEL to skip the
  283. remainder of this repetition of the macro and start right away with the
  284. next repetition.  ESC means to skip the remainder of this repetition
  285. and cancel further repetitions.  `C-l' redraws the screen and asks you
  286. again for a character to say what to do.
  287.  
  288.    `C-r' enters a recursive editing level, in which you can perform
  289. editing which is not part of the macro.  When you exit the recursive
  290. edit using `C-M-c', you are asked again how to continue with the
  291. keyboard macro.  If you type a SPC at this time, the rest of the macro
  292. definition is executed.  It is up to you to leave point and the text in
  293. a state such that the rest of the macro will do what you want.
  294.  
  295.    `C-u C-x q', which is `C-x q' with a numeric argument, performs a
  296. completely different function.  It enters a recursive edit reading
  297. input from the keyboard, both when you type it during the definition of
  298. the macro, and when it is executed from the macro.  During definition,
  299. the editing you do inside the recursive edit does not become part of
  300. the macro.  During macro execution, the recursive edit gives you a
  301. chance to do some particularized editing on each repetition.  *Note
  302. Recursive Edit::.
  303.  
  304. 
  305. File: emacs,  Node: Key Bindings,  Next: Keyboard Translations,  Prev: Keyboard Macros,  Up: Customization
  306.  
  307. Customizing Key Bindings
  308. ========================
  309.  
  310.    This section describes "key bindings" which map keys to commands,
  311. and the "keymaps" which record key bindings.  It also explains how to
  312. customize key bindings.
  313.  
  314.    Recall that a command is a Lisp function whose definition provides
  315. for interactive use.  Like every Lisp function, a command has a function
  316. name which usually consists of lower case letters and hyphens.
  317.  
  318. * Menu:
  319.  
  320. * Keymaps::          Generalities.  The global keymap.
  321. * Prefix Keymaps::   Keymaps for prefix keys.
  322. * Local Keymaps::    Major and minor modes have their own keymaps.
  323. * Minibuffer Maps::  The minibuffer uses its own local keymaps.
  324. * Rebinding::        How to redefine one key's meaning conveniently.
  325. * Init Rebinding::   Rebinding keys with your init file, `.emacs'.
  326. * Function Keys::    Rebinding terminal function keys.
  327. * Named ASCII Chars::Distinguishing TAB from `C-i', and so on.
  328. * Mouse Buttons::    Rebinding mouse buttons in Emacs.
  329. * Disabling::        Disabling a command means confirmation is required
  330.                        before it can be executed.  This is done to protect
  331.                        beginners from surprises.
  332.  
  333. 
  334. File: emacs,  Node: Keymaps,  Next: Prefix Keymaps,  Up: Key Bindings
  335.  
  336. Keymaps
  337. -------
  338.  
  339.    The bindings between key sequences and command functions are recorded
  340. in data structures called "keymaps".  Emacs has many of these, each
  341. used on particular occasions.
  342.  
  343.    Recall that a "key sequence" ("key", for short) is a sequence of
  344. "input events" that have a meaning as a unit.  Input events include
  345. characters, function keys and mouse buttons--all the inputs that you
  346. can send to the computer with your terminal.  A key sequence gets its
  347. meaning from its "binding", which says what command it runs.  The
  348. function of keymaps is to record these bindings.
  349.  
  350.    The "global" keymap is the most important keymap because it is
  351. always in effect.  The global keymap defines keys for Fundamental mode;
  352. most of these definitions are common to most or all major modes.  Each
  353. major or minor mode can have its own keymap which overrides the global
  354. definitions of some keys.
  355.  
  356.    For example, a self-inserting character such as `g' is
  357. self-inserting because the global keymap binds it to the command
  358. `self-insert-command'.  The standard Emacs editing characters such as
  359. `C-a' also get their standard meanings from the global keymap.
  360. Commands to rebind keys, such as `M-x global-set-key', actually work by
  361. storing the new binding in the proper place in the global map.  *Note
  362. Rebinding::.
  363.  
  364.    Meta characters work differently; Emacs translates each Meta
  365. character into a pair of characters starting with ESC.  When you type
  366. the character `M-a' in a key sequence, Emacs replaces it with `ESC a'.
  367. A meta key comes in as a single input event, but becomes two events for
  368. purposes of key bindings.  The reason for this is historical, and we
  369. might change it someday.
  370.  
  371.    Most modern keyboards have function keys as well as character keys.
  372. Function keys send input events just as character keys do, and keymaps
  373. can have bindings for them.
  374.  
  375.    On many terminals, typing a function key actually sends the computer
  376. a sequence of characters; the precise details of the sequence depends on
  377. which function key and on the model of terminal you are using.  (Often
  378. the sequence starts with `ESC ['.)  If Emacs understands your terminal
  379. type properly, it recognizes the character sequences forming function
  380. keys wherever they occur in a key sequence (not just at the beginning).
  381. Thus, for most purposes, you can pretend the function keys reach Emacs
  382. directly and ignore their encoding as character sequences.
  383.  
  384.    Mouse buttons also produce input events.  These events come with
  385. other data--the window and position where you pressed or released the
  386. button, and a time stamp.  But only the choice of button matters for key
  387. bindings; the other data matters only if a command looks at it.
  388. (Commands designed for mouse invocation usually do look at the other
  389. data.)
  390.  
  391.    A keymap records definitions for single events.  Interpreting a key
  392. sequence of multiple events involves a chain of keymaps.  The first
  393. keymap gives a definition for the first event; this definition is
  394. another keymap, which is used to look up the second event in the
  395. sequence, and so on.
  396.  
  397.    Key sequences can mix function keys and characters.  For example,
  398. `C-x SELECT' makes sense.  If you make SELECT a prefix key, then
  399. `SELECT C-n' makes sense.  You can even mix mouse events with keyboard
  400. events, but we recommend against it, because such sequences are
  401. inconvenient to type in.
  402.  
  403. 
  404. File: emacs,  Node: Prefix Keymaps,  Next: Local Keymaps,  Prev: Keymaps,  Up: Key Bindings
  405.  
  406. Prefix Keymaps
  407. --------------
  408.  
  409.    A prefix key such as `C-x' or ESC has its own keymap, which holds
  410. the definition for the event that immediately follows that prefix.
  411.  
  412.    The definition of a prefix key is usually the keymap to use for
  413. looking up the following event.  The definition can also be a Lisp
  414. symbol whose function definition is the following keymap; the effect is
  415. the same, but it provides a command name for the prefix key that can be
  416. used as a description of what the prefix key is for.  Thus, the binding
  417. of `C-x' is the symbol `Ctl-X-Prefix', whose function definition is the
  418. keymap for `C-x' commands.  The definitions of `C-c', `C-x', `C-h' and
  419. ESC as prefix keys appear in the global map, so these prefix keys are
  420. always available.
  421.  
  422.    Some prefix keymaps are stored in variables with names:
  423.  
  424.    * `ctl-x-map' is the variable name for the map used for characters
  425.      that follow `C-x'.
  426.  
  427.    * `help-map' is for characters that follow `C-h'.
  428.  
  429.    * `esc-map' is for characters that follow ESC.  Thus, all Meta
  430.      characters are actually defined by this map.
  431.  
  432.    * `ctl-x-4-map' is for characters that follow `C-x 4'.
  433.  
  434.    * `mode-specific-map' is for characters that follow `C-c'.
  435.  
  436. 
  437. File: emacs,  Node: Local Keymaps,  Next: Minibuffer Maps,  Prev: Prefix Keymaps,  Up: Key Bindings
  438.  
  439. Local Keymaps
  440. -------------
  441.  
  442.    So far we have explained the ins and outs of the global map.  Major
  443. modes customize Emacs by providing their own key bindings in "local
  444. keymaps".  For example, C mode overrides TAB to make it indent the
  445. current line for C code.  Portions of text in the buffer can specify
  446. their own keymaps to substitute for the keymap of the buffer's major
  447. mode.
  448.  
  449.    Minor modes can also have local keymaps.  Whenever a minor mode is
  450. in effect, the definitions in its keymap override both the major mode's
  451. local keymap and the global keymap.
  452.  
  453.    The local keymaps for Lisp mode, C mode, and several other major
  454. modes always exist even when not in use.  These are kept in variables
  455. named `lisp-mode-map', `c-mode-map', and so on.  For major modes less
  456. often used, the local keymap is normally constructed only when the mode
  457. is used for the first time in a session.  This is to save space.
  458.  
  459.    All minor mode keymaps are created in advance.  There is no way to
  460. defer their creation until the first time the minor mode is enabled.
  461.  
  462.    A local keymap can locally redefine a key as a prefix key by defining
  463. it as a prefix keymap.  If the key is also defined globally as a prefix,
  464. then its local and global definitions (both keymaps) effectively
  465. combine: both of them are used to look up the event that follows the
  466. prefix key.  Thus, if the mode's local keymap defines `C-c' as another
  467. keymap, and that keymap defines `C-z' as a command, this provides a
  468. local meaning for `C-c C-z'.  This does not affect other sequences that
  469. start with `C-c'; if those sequences don't have their own local
  470. bindings, their global bindings remain in effect.
  471.  
  472.    Another way to think of this is that Emacs handles a multi-event key
  473. sequence by looking in several keymaps, one by one, for a binding of the
  474. whole key sequence.  First it checks the minor mode keymaps for minor
  475. modes that are enabled, then it checks the major mode's keymap, and then
  476. it checks the global keymap.  This is not precisely how key lookup
  477. works, but it's good enough for understanding ordinary circumstances.
  478.  
  479. 
  480. File: emacs,  Node: Minibuffer Maps,  Next: Rebinding,  Prev: Local Keymaps,  Up: Key Bindings
  481.  
  482. Minibuffer Keymaps
  483. ------------------
  484.  
  485.    The minibuffer has its own set of local keymaps; they contain various
  486. completion and exit commands.
  487.  
  488.    * `minibuffer-local-map' is used for ordinary input (no completion).
  489.  
  490.    * `minibuffer-local-ns-map' is similar, except that SPC exits just
  491.      like RET.  This is used mainly for Mocklisp compatibility.
  492.  
  493.    * `minibuffer-local-completion-map' is for permissive completion.
  494.  
  495.    * `minibuffer-local-must-match-map' is for strict completion and for
  496.      cautious completion.
  497.  
  498. 
  499. File: emacs,  Node: Rebinding,  Next: Init Rebinding,  Prev: Minibuffer Maps,  Up: Key Bindings
  500.  
  501. Changing Key Bindings Interactively
  502. -----------------------------------
  503.  
  504.    The way to redefine an Emacs key is to change its entry in a keymap.
  505. You can change the global keymap, in which case the change is effective
  506. in all major modes (except those that have their own overriding local
  507. definitions for the same key).  Or you can change the current buffer's
  508. local map, which affects all buffers using the same major mode.
  509.  
  510. `M-x global-set-key RET KEY CMD RET'
  511.      Define KEY globally to run CMD.
  512.  
  513. `M-x local-set-key RET KEY CMD RET'
  514.      Define KEY locally (in the major mode now in effect) to run CMD.
  515.  
  516. `M-x global-unset-key RET KEY'
  517.      Make KEY undefined in the global map.
  518.  
  519. `M-x local-unset-key RET KEY'
  520.      Make KEY undefined locally (in the major mode now in effect).
  521.  
  522.    For example, suppose you like to execute commands in a subshell
  523. within an Emacs buffer, instead of suspending Emacs and executing
  524. commands in your login shell.  Normally, `C-z' is bound to the function
  525. `suspend-emacs' (when not using the X Window System), but you can
  526. change `C-z' to invoke an interactive subshell within Emacs, by binding
  527. it to `shell' as follows:
  528.  
  529.      M-x global-set-key RET C-z shell RET
  530.  
  531. `global-set-key' reads the command name after the key.   After you
  532. press the key, a message like this appears so that you can confirm that
  533. you are binding the key you want:
  534.  
  535.      Set key C-z to command:
  536.  
  537.    You can redefine function keys and mouse events in the same way; just
  538. type the function key or click the mouse when it's time to specify the
  539. key to rebind.
  540.  
  541.    You can rebind a key that contains more than one event in the same
  542. way.  Emacs keeps reading the key to rebind until it is a complete key
  543. (that is, not a prefix key).  Thus, if you type `C-f' for KEY, that's
  544. the end; the minibuffer is entered immediately to read CMD.  But if you
  545. type `C-x', another character is read; if that is `4', another
  546. character is read, and so on.  For example,
  547.  
  548.      M-x global-set-key RET C-x 4 $ spell-other-window RET
  549.  
  550. redefines `C-x 4 $' to run the (fictitious) command
  551. `spell-other-window'.
  552.  
  553.    The two-character keys consisting of `C-c' followed by a letter are
  554. reserved for user customizations.  Lisp programs are not supposed to
  555. define these keys, so the bindings you make for them will be available
  556. in all major modes and will never get in the way of anything.
  557.  
  558.    You can remove the global definition of a key with
  559. `global-unset-key'.  This makes the key "undefined"; if you type it,
  560. Emacs will just beep.  Similarly, `local-unset-key' makes a key
  561. undefined in the current major mode keymap, which makes the global
  562. definition (or lack of one) come back into effect in that major mode.
  563.  
  564.    If you have redefined (or undefined) a key and you subsequently wish
  565. to retract the change, undefining the key will not do the job--you need
  566. to redefine the key with its standard definition.  To find the name of
  567. the standard definition of a key, go to a Fundamental mode buffer and
  568. use `C-h c'.  The documentation of keys in this manual also lists their
  569. command names.
  570.  
  571.    If you want to prevent yourself from invoking a command by mistake,
  572. it is better to disable the command than to undefine the key.  A
  573. disabled command is less work to invoke when you really want to.  *Note
  574. Disabling::.
  575.  
  576. 
  577. File: emacs,  Node: Init Rebinding,  Next: Function Keys,  Prev: Rebinding,  Up: Key Bindings
  578.  
  579. Rebinding Keys in Your Init File
  580. --------------------------------
  581.  
  582.    If you have a set of key bindings that you like to use all the time,
  583. you can specify them in your `.emacs' file by using their Lisp syntax.
  584. Thus, the first `global-set-key' command in this section could be put
  585. in an `.emacs' file in either of the two following formats:
  586.  
  587.      (global-set-key "\C-z" 'shell)
  588.  
  589. or:
  590.  
  591.      (global-set-key [?\C-z] 'shell)
  592.  
  593. When the key sequence consists of ASCII characters and Meta-modified
  594. ASCII characters, like this one, you can write it as a string or as a
  595. vector.  The first format specifies the key sequence as a string,
  596. `"\C-z"'.  The second format uses a vector to specify the key sequence.
  597. The square brackets (`[...]') delimit the contents of the vector.  The
  598. vector in this example contains just one element, which is the integer
  599. code corresponding to `C-z'.  The question mark is the Lisp syntax for
  600. a character constant; the character must follow with no intervening
  601. spaces.
  602.  
  603.    The single-quote before `shell' marks it as a constant symbol rather
  604. than a variable.  If you omit the quote, Emacs tries to evaluate
  605. `shell' immediately as a variable.  This probably causes an error; it
  606. certainly isn't what you want.
  607.  
  608.    Here is another example that binds a key sequence two characters
  609. long:
  610.  
  611.      (global-set-key "\C-xl" 'make-symbolic-link)
  612.  
  613. or:
  614.  
  615.      (global-set-key [?\C-x ?l] 'make-symbolic-link)
  616.  
  617.    When the key sequence includes function keys or mouse button events,
  618. or non-ASCII characters such as `C-=' or `H-a', you must use a vector:
  619.  
  620.      (global-set-key [?\C-=] 'make-symbolic-link)
  621.      (global-set-key [?\H-a] 'make-symbolic-link)
  622.      (global-set-key [C-H-mouse-1] 'make-symbolic-link)
  623.  
  624. 
  625. File: emacs,  Node: Function Keys,  Next: Named ASCII Chars,  Prev: Init Rebinding,  Up: Key Bindings
  626.  
  627. Rebinding Function Keys
  628. -----------------------
  629.  
  630.    Key sequences can contain function keys as well as ordinary
  631. characters.  Just as Lisp characters (actually integers) represent
  632. keyboard characters, Lisp symbols represent function keys.  If the
  633. function key has a word as its label, then that word is also the name of
  634. the corresponding Lisp symbol.  Here are the conventional Lisp names for
  635. common function keys:
  636.  
  637. `left', `up', `right', `down'
  638.      Cursor arrow keys.
  639.  
  640. `begin', `end', `home', `next', `prior'
  641.      Other cursor repositioning keys.
  642.  
  643. `select', `print', `execute', `backtab'
  644. `insert', `undo', `redo', `clearline'
  645. `insertline', `deleteline', `insertchar', `deletechar',
  646.      Miscellaneous function keys.
  647.  
  648. `f1', `f2', ... `f35'
  649.      Numbered function keys (across the top of the keyboard).
  650.  
  651. `kp-add', `kp-subtract', `kp-multiply', `kp-divide'
  652. `kp-backtab', `kp-space', `kp-tab', `kp-enter'
  653. `kp-separator', `kp-decimal', `kp-equal'
  654.      Keypad keys (to the right of the regular keyboard), with names or
  655.      punctuation.
  656.  
  657. `kp-0', `kp-1', ... `kp-9'
  658.      Keypad keys with digits.
  659.  
  660. `kp-f1', `kp-f2', `kp-f3', `kp-f4'
  661.      Keypad PF keys.
  662.  
  663.    These names are conventional, but some systems (especially when using
  664. X windows) may use different names.  To make certain what symbol is used
  665. for a given function key on your terminal, type `C-h c' followed by
  666. that key.
  667.  
  668.    A key sequence which contains non-characters must be a vector rather
  669. than a string.  To write a vector, write square brackets containing the
  670. vector elements.  Write spaces to separate the elements.  If an element
  671. is a symbol, simply write the symbol's name--no delimiters or
  672. punctuation are needed.  If an element is a character, write a Lisp
  673. character constant, which is `?' followed by the character as it would
  674. appear in a string.
  675.  
  676.    Thus, to bind function key `f1' to the command `rmail', write the
  677. following:
  678.  
  679.      (global-set-key [f1] 'rmail)
  680.  
  681. To bind the right-arrow key to the command `forward-char', you can use
  682. this expression:
  683.  
  684.      (global-set-key [right] 'forward-char)
  685.  
  686. This uses the Lisp syntax for a vector containing the symbol `right'.
  687. (This binding is present in Emacs by default.)
  688.  
  689.    You can mix function keys and characters in a key sequence.  This
  690. example binds `C-x RIGHT' to the command `forward-page'.
  691.  
  692.      (global-set-key [?\C-x right] 'forward-page)
  693.  
  694. where `?\C-x' is the Lisp character constant for the character `C-x'.
  695. The vector element `right' is a symbol and therefore does not take a
  696. question mark.
  697.  
  698.    You can use the modifier keys CTRL, META, HYPER, SUPER, ALT and
  699. SHIFT with function keys.  To represent these modifiers, add the
  700. strings `C-', `M-', `H-', `s-', `A-' and `S-' at the front of the
  701. symbol name.  Thus, here is how to make `Hyper-Meta-RIGHT' move forward
  702. a word:
  703.  
  704.      (global-set-key [H-M-right] 'forward-word)
  705.  
  706. 
  707. File: emacs,  Node: Named ASCII Chars,  Next: Mouse Buttons,  Prev: Function Keys,  Up: Key Bindings
  708.  
  709. Named ASCII Control Characters
  710. ------------------------------
  711.  
  712.    TAB, RET, BS, LFD, ESC and DEL started out as names for certain
  713. ASCII control characters, used so often that they have special keys of
  714. their own.  Later, users found it convenient to distinguish in Emacs
  715. between these keys and the "same" control characters typed with the
  716. CTRL key.
  717.  
  718.    Emacs 19 distinguishes these two kinds of input, when used with the X
  719. Window System.  It treats the "special" keys as function keys named
  720. `tab', `return', `backspace', `linefeed', `escape', and `delete'.
  721. These function keys translate automatically into the corresponding
  722. ASCII characters *if* they have no bindings of their own.  As a result,
  723. neither users nor Lisp programs need to pay attention to the
  724. distinction unless they care to.
  725.  
  726.    If you do not want to distinguish between (for example) TAB and
  727. `C-i', make just one binding, for the ASCII character TAB (octal code
  728. 011).  If you do want to distinguish, make one binding for this ASCII
  729. character, and another for the "function key" `tab'.
  730.  
  731.    With an ordinary ASCII terminal, there is no way to distinguish
  732. between TAB and `C-i' (and likewise for other such pairs), because the
  733. terminal sends the same character in both cases.
  734.  
  735. 
  736. File: emacs,  Node: Mouse Buttons,  Next: Disabling,  Prev: Named ASCII Chars,  Up: Key Bindings
  737.  
  738. Rebinding Mouse Buttons
  739. -----------------------
  740.  
  741.    Emacs uses Lisp symbols to designate mouse buttons, too.  The
  742. ordinary mouse events in Emacs are "click" events; these happen when you
  743. press a button and release it without moving the mouse.  You can also
  744. get "drag" events, when you move the mouse while holding the button
  745. down.  Drag events happen when you finally let go of the button.
  746.  
  747.    The symbols for basic click events are `mouse-1' for the leftmost
  748. button, `mouse-2' for the next, and so on.  Here is how you can
  749. redefine the second mouse button to split the current window:
  750.  
  751.      (global-set-key [mouse-2] 'split-window-vertically)
  752.  
  753.    The symbols for drag events are similar, but have the prefix `drag-'
  754. before the word `mouse'.  For example, dragging the first button
  755. generates a `drag-mouse-1' event.
  756.  
  757.    You can also define bindings for events that occur when a mouse
  758. button is pressed down.  These events start with `down-' instead of
  759. `drag-'.  Such events are generated only if they have key bindings.
  760. When you get a button-down event, a corresponding click or drag event
  761. will always follow.
  762.  
  763.    If you wish, you can distinguish single, double, and triple clicks.
  764. A double click means clicking a mouse button twice in approximately the
  765. same place.  The first click generates an ordinary click event.  The
  766. second click, if it comes soon enough, generates a double-click event
  767. instead.  The event type for a double click event starts with
  768. `double-': for example, `double-mouse-3'.
  769.  
  770.    This means that you can give a special meaning to the second click at
  771. the same place, but it must act on the assumption that the ordinary
  772. single click definition has run when the first click was received.
  773.  
  774.    This constrains what you can do with double clicks, but user
  775. interface designers say that this constraint ought to be followed in
  776. any case.  A double click should do something similar to the single
  777. click, only "more so".  The command for the double-click event should
  778. perform the extra work for the double click.
  779.  
  780.    If a double-click event has no binding, it changes to the
  781. corresponding single-click event.  Thus, if you don't define a
  782. particular double click specially, it executes the single-click command
  783. twice.
  784.  
  785.    Emacs also supports triple-click events whose names start with
  786. `triple-'.  Emacs does not distinguish quadruple clicks as event types;
  787. clicks beyond the third generate additional triple-click events.
  788. However, the full number of clicks is recorded in the event list, so you
  789. can distinguish if you really want to.  We don't recommend distinct
  790. meanings for more than three clicks, but sometimes it is useful for
  791. subsequent clicks to cycle through the same set of three meanings, so
  792. that four clicks are equivalent to one click, five are equivalent to
  793. two, and six are equivalent to three.
  794.  
  795.    Emacs also records multiple presses in drag and button-down events.
  796. For example, when you press a button twice, then move the mouse while
  797. holding the button, Emacs gets a `double-drag-' event.  And at the
  798. moment when you press it down for the second time, Emacs gets a
  799. `double-down-' event (which is ignored, like all button-down events, if
  800. it has no binding).
  801.  
  802.    The variable `double-click-time' specifies how long may elapse
  803. between clicks that are recognized as a pair.  Its value is measured in
  804. milliseconds.  If the value is `nil', double clicks are not detected at
  805. all.  If the value is `t', then there is no time limit.
  806.  
  807.    The symbols for mouse events also indicate the status of the modifier
  808. keys, with the usual prefixes `C-', `M-', `H-', `s-', `A-' and `S-'.
  809. These always precede `double-' or `triple-', which always precede
  810. `drag-' or `down-'.
  811.  
  812.    A frame includes areas that don't show text from the buffer, such as
  813. the mode line and the scroll bar.  You can tell whether a mouse button
  814. comes from a special area of the screen by means of dummy "prefix
  815. keys."  For example, if you click the mouse in the mode line, you get
  816. the prefix key `mode-line' before the ordinary mouse-button symbol.
  817. Thus, here is how to define the command for clicking the first button in
  818. a mode line to run `scroll-up':
  819.  
  820.      (global-set-key [mode-line mouse-1] 'scroll-up)
  821.  
  822.    Here is the complete list of these dummy prefix keys and their
  823. meanings:
  824.  
  825. `mode-line'
  826.      The mouse was in the mode line of a window.
  827.  
  828. `vertical-line'
  829.      The mouse was in the vertical line separating side-by-side
  830.      windows.  (If you use scroll bars, they appear in place of these
  831.      vertical lines.)
  832.  
  833. `vertical-scroll-bar'
  834.      The mouse was in a vertical scroll bar.  (This is the only kind of
  835.      scroll bar Emacs currently supports.)
  836.  
  837.    You can put more than one mouse button in a key sequence, but it
  838. isn't usual to do so.
  839.  
  840. 
  841. File: emacs,  Node: Disabling,  Prev: Mouse Buttons,  Up: Key Bindings
  842.  
  843. Disabling Commands
  844. ------------------
  845.  
  846.    Disabling a command marks the command as requiring confirmation
  847. before it can be executed.  The purpose of disabling a command is to
  848. prevent beginning users from executing it by accident and being
  849. confused.
  850.  
  851.    An attempt to invoke a disabled command interactively in Emacs
  852. displays a window containing the command's name, its documentation, and
  853. some instructions on what to do immediately; then Emacs asks for input
  854. saying whether to execute the command as requested, enable it and
  855. execute it, or cancel.  If you decide to enable the command, you are
  856. asked whether to do this permanently or just for the current session.
  857. Enabling permanently works by automatically editing your `.emacs' file.
  858.  
  859.    The direct mechanism for disabling a command is to put a non-`nil'
  860. `disabled' property on the Lisp symbol for the command.  Here is the
  861. Lisp program to do this:
  862.  
  863.      (put 'delete-region 'disabled t)
  864.  
  865.    If the value of the `disabled' property is a string, that string is
  866. included in the message printed when the command is used:
  867.  
  868.      (put 'delete-region 'disabled
  869.           "It's better to use `kill-region' instead.\n")
  870.  
  871.    You can make a command disabled either by editing the `.emacs' file
  872. directly or with the command `M-x disable-command', which edits the
  873. `.emacs' file for you.  Likewise, `M-x enable-command' edits `.emacs'
  874. to enable a command permanently.  *Note Init File::.
  875.  
  876.    Whether a command is disabled is independent of what key is used to
  877. invoke it; disabling also applies if the command is invoked using
  878. `M-x'.  Disabling a command has no effect on calling it as a function
  879. from Lisp programs.
  880.  
  881. 
  882. File: emacs,  Node: Keyboard Translations,  Next: Syntax,  Prev: Key Bindings,  Up: Customization
  883.  
  884. Keyboard Translations
  885. =====================
  886.  
  887.    Some keyboards do not make it convenient to send all the special
  888. characters that Emacs uses.  The most common problem case is the DEL
  889. character.  Some keyboards provide no convenient way to type this very
  890. important character--usually because they were designed to expect the
  891. character `C-h' to be used for deletion.  On these keyboard, if you
  892. press the key normally used for deletion, Emacs handles the `C-h' as a
  893. prefix character and offers you a list of help options, which is not
  894. what you want.
  895.  
  896.    You can work around this problem within Emacs by setting up keyboard
  897. translations to turn `C-h' into DEL and DEL into `C-h', as follows:
  898.  
  899.      ;; Translate `C-h' to DEL.
  900.      (keyboard-translate ?\C-h ?\C-?)
  901.      ;; Translate DEL to `C-h'.
  902.      (keyboard-translate ?\C-? ?\C-h)
  903.  
  904.    Keyboard translations are not the same as key bindings in keymaps
  905. (*note Keymaps::.).  Emacs contains numerous keymaps that apply in
  906. different situations, but there is only one set of keyboard
  907. translations, and it applies to every character that Emacs reads from
  908. the terminal.  Keyboard translations take place at the lowest level of
  909. input processing; the keys that are looked up in keymaps contain the
  910. characters that result from keyboard translation.
  911.  
  912.    Under X, the keyboard key named DEL acts like a function key and is
  913. distinct from the ASCII character named DEL.  *Note Named ASCII
  914. Chars::.  Keyboard translations affect only ASCII character input, not
  915. function keys; thus, the above example used under X will not do what you
  916. probably want.  However, you can remap the keyboard keys using
  917. `xmodmap' when using X.
  918.  
  919.    For full information about how to use keyboard translations, see
  920. *Note Translating Input: (elisp)Translating Input.
  921.  
  922. 
  923. File: emacs,  Node: Syntax,  Next: Init File,  Prev: Keyboard Translations,  Up: Customization
  924.  
  925. The Syntax Table
  926. ================
  927.  
  928.    All the Emacs commands which parse words or balance parentheses are
  929. controlled by the "syntax table".  The syntax table says which
  930. characters are opening delimiters, which are parts of words, which are
  931. string quotes, and so on.  Each major mode has its own syntax table
  932. (though sometimes related major modes use the same one) which it
  933. installs in each buffer that uses that major mode.  The syntax table
  934. installed in the current buffer is the one that all commands use, so we
  935. call it "the" syntax table.  A syntax table is a Lisp object, a vector
  936. of length 256 whose elements are numbers.
  937.  
  938.    To display a description of the contents of the current syntax table,
  939. type `C-h s' (`describe-syntax').  The description of each character
  940. includes both the string you would have to give to
  941. `modify-syntax-entry' to set up that character's current syntax, and
  942. some English to explain that string if necessary.
  943.  
  944.    For full information on the syntax table, see *Note Syntax Tables:
  945. (elisp)Syntax Tables.
  946.  
  947. 
  948. File: emacs,  Node: Init File,  Prev: Syntax,  Up: Customization
  949.  
  950. The Init File, `~/.emacs'
  951. =========================
  952.  
  953.    When Emacs is started, it normally loads a Lisp program from the file
  954. `.emacs' in your home directory.  We call this file your "init file"
  955. because it specifies how to initialize Emacs for you.  You can use the
  956. command line switches `-q' and `-u' to tell Emacs whether to load an
  957. init file, and which one (*note Entering Emacs::.).
  958.  
  959.    There can also be a "default init file", which is the library named
  960. `default.el', found via the standard search path for libraries.  The
  961. Emacs distribution contains no such library; your site may create one
  962. for local customizations.  If this library exists, it is loaded
  963. whenever you start Emacs (except when you specify `-q').  But your init
  964. file, if any, is loaded first; if it sets `inhibit-default-init'
  965. non-`nil', then `default' is not loaded.
  966.  
  967.    Your site may also have a "site startup file"; this is named
  968. `site-start.el', if it exists.  Emacs loads this library before it
  969. loads your init file.  To inhibit loading of this library, use the
  970. option `-no-site-file'.
  971.  
  972.    If you have a large amount of code in your `.emacs' file, you should
  973. move it into another file such as `~/SOMETHING.el', byte-compile it,
  974. and make your `.emacs' file load it with `(load "~/SOMETHING")'.  *Note
  975. Byte Compilation: (elisp)Byte Compilation, for more information about
  976. compiling Emacs Lisp programs.
  977.  
  978. * Menu:
  979.  
  980. * Init Syntax::         Syntax of constants in Emacs Lisp.
  981. * Init Examples::    How to do some things with an init file.
  982. * Terminal Init::    Each terminal type can have an init file.
  983. * Find Init::         How Emacs finds the init file.
  984.  
  985. 
  986. File: emacs,  Node: Init Syntax,  Next: Init Examples,  Up: Init File
  987.  
  988. Init File Syntax
  989. ----------------
  990.  
  991.    The `.emacs' file contains one or more Lisp function call
  992. expressions.  Each of these consists of a function name followed by
  993. arguments, all surrounded by parentheses.  For example, `(setq
  994. fill-column 60)' calls the function `setq' to set the variable
  995. `fill-column' (*note Filling::.) to 60.
  996.  
  997.    The second argument to `setq' is an expression for the new value of
  998. the variable.  This can be a constant, a variable, or a function call
  999. expression.  In `.emacs', constants are used most of the time.  They
  1000. can be:
  1001.  
  1002. Numbers:
  1003.      Numbers are written in decimal, with an optional initial minus
  1004.      sign.
  1005.  
  1006. Strings:
  1007.      Lisp string syntax is the same as C string syntax with a few extra
  1008.      features.  Use a double-quote character to begin and end a string
  1009.      constant.
  1010.  
  1011.      In a string, you can include newlines and special characters
  1012.      literally.  But often it is cleaner to use backslash sequences for
  1013.      them: `\n' for newline, `\b' for backspace, `\r' for carriage
  1014.      return, `\t' for tab, `\f' for formfeed (control-L), `\e' for
  1015.      escape, `\\' for a backslash, `\"' for a double-quote, or `\OOO'
  1016.      for the character whose octal code is OOO.  Backslash and
  1017.      double-quote are the only characters for which backslash sequences
  1018.      are mandatory.
  1019.  
  1020.      `\C-' can be used as a prefix for a control character, as in
  1021.      `\C-s' for ASCII control-S, and `\M-' can be used as a prefix for
  1022.      a Meta character, as in `\M-a' for `Meta-A' or `\M-\C-a' for
  1023.      `Control-Meta-A'.
  1024.  
  1025. Characters:
  1026.      Lisp character constant syntax consists of a `?' followed by
  1027.      either a character or an escape sequence starting with `\'.
  1028.      Examples: `?x', `?\n', `?\"', `?\)'.  Note that strings and
  1029.      characters are not interchangeable in Lisp; some contexts require
  1030.      one and some contexts require the other.
  1031.  
  1032. True:
  1033.      `t' stands for `true'.
  1034.  
  1035. False:
  1036.      `nil' stands for `false'.
  1037.  
  1038. Other Lisp objects:
  1039.      Write a single-quote (') followed by the Lisp object you want.
  1040.  
  1041. 
  1042. File: emacs,  Node: Init Examples,  Next: Terminal Init,  Prev: Init Syntax,  Up: Init File
  1043.  
  1044. Init File Examples
  1045. ------------------
  1046.  
  1047.    Here are some examples of doing certain commonly desired things with
  1048. Lisp expressions:
  1049.  
  1050.    * Make TAB in C mode just insert a tab if point is in the middle of a
  1051.      line.
  1052.  
  1053.           (setq c-tab-always-indent nil)
  1054.  
  1055.      Here we have a variable whose value is normally `t' for `true' and
  1056.      the alternative is `nil' for `false'.
  1057.  
  1058.    * Make searches case sensitive by default (in all buffers that do not
  1059.      override this).
  1060.  
  1061.           (setq-default case-fold-search nil)
  1062.  
  1063.      This sets the default value, which is effective in all buffers
  1064.      that do not have local values for the variable.  Setting
  1065.      `case-fold-search' with `setq' affects only the current buffer's
  1066.      local value, which is not what you probably want to do in an init
  1067.      file.
  1068.  
  1069.    * Specify your own email address, if Emacs can't figure it out
  1070.      correctly.
  1071.  
  1072.           (setq user-mail-address "coon@yoyodyne.com")
  1073.  
  1074.      Various Emacs packages that need to use your own email address use
  1075.      the value of `user-mail-address'.
  1076.  
  1077.    * Make Text mode the default mode for new buffers.
  1078.  
  1079.           (setq default-major-mode 'text-mode)
  1080.  
  1081.      Note that `text-mode' is used because it is the command for
  1082.      entering Text mode.  The single-quote before it makes the symbol a
  1083.      constant; otherwise, `text-mode' would be treated as a variable
  1084.      name.
  1085.  
  1086.    * Turn on Auto Fill mode automatically in Text mode and related
  1087.      modes.
  1088.  
  1089.           (add-hook 'text-mode-hook
  1090.             '(lambda () (auto-fill-mode 1)))
  1091.  
  1092.      This shows how to add a hook function to a normal hook variable
  1093.      (*note Hooks::.).  The function we supply is a list starting with
  1094.      `lambda', with a single-quote in front of it to make it a list
  1095.      constant rather than an expression.
  1096.  
  1097.      It's beyond the scope of this manual to explain Lisp functions,
  1098.      but for this example it is enough to know that the effect is to
  1099.      execute `(auto-fill-mode 1)' when Text mode is entered.  You can
  1100.      replace that with any other expression that you like, or with
  1101.      several expressions in a row.
  1102.  
  1103.      Emacs comes with a function named `turn-on-auto-fill' whose
  1104.      definition is `(lambda () (auto-fill-mode 1))'.  Thus, a simpler
  1105.      way to write the above example is as follows:
  1106.  
  1107.           (add-hook 'text-mode-hook 'turn-on-auto-fill)
  1108.  
  1109.    * Load the installed Lisp library named `foo' (actually a file
  1110.      `foo.elc' or `foo.el' in a standard Emacs directory).
  1111.  
  1112.           (load "foo")
  1113.  
  1114.      When the argument to `load' is a relative file name, not starting
  1115.      with `/' or `~', `load' searches the directories in `load-path'
  1116.      (*note Lisp Libraries::.).
  1117.  
  1118.    * Load the compiled Lisp file `foo.elc' from your home directory.
  1119.  
  1120.           (load "~/foo.elc")
  1121.  
  1122.      Here an absolute file name is used, so no searching is done.
  1123.  
  1124.    * Rebind the key `C-x l' to run the function `make-symbolic-link'.
  1125.  
  1126.           (global-set-key "\C-xl" 'make-symbolic-link)
  1127.  
  1128.      or
  1129.  
  1130.           (define-key global-map "\C-xl" 'make-symbolic-link)
  1131.  
  1132.      Note once again the single-quote used to refer to the symbol
  1133.      `make-symbolic-link' instead of its value as a variable.
  1134.  
  1135.    * Do the same thing for C mode only.
  1136.  
  1137.           (define-key c-mode-map "\C-xl" 'make-symbolic-link)
  1138.  
  1139.    * Redefine all keys which now run `next-line' in Fundamental mode so
  1140.      that they run `forward-line' instead.
  1141.  
  1142.           (substitute-key-definition 'next-line 'forward-line
  1143.                                      global-map)
  1144.  
  1145.    * Make `C-x C-v' undefined.
  1146.  
  1147.           (global-unset-key "\C-x\C-v")
  1148.  
  1149.      One reason to undefine a key is so that you can make it a prefix.
  1150.      Simply defining `C-x C-v ANYTHING' will make `C-x C-v' a prefix,
  1151.      but `C-x C-v' must first be freed of its usual non-prefix
  1152.      definition.
  1153.  
  1154.    * Make `$' have the syntax of punctuation in Text mode.  Note the
  1155.      use of a character constant for `$'.
  1156.  
  1157.           (modify-syntax-entry ?\$ "." text-mode-syntax-table)
  1158.  
  1159.    * Enable the use of the command `eval-expression' without
  1160.      confirmation.
  1161.  
  1162.           (put 'eval-expression 'disabled nil)
  1163.  
  1164.